<template>
    <!-- 查询条件 -->
    <el-form :inline="true" :model="show" class="demo-form-inline">
        <el-form-item label="客户名称">
            <el-input v-model="show.AClientName" placeholder="客户名称" clearable />
        </el-form-item>
        <el-form-item label="关联销售合同">
            <el-input v-model="show.ContractTopic" placeholder="关联销售合同" clearable />
        </el-form-item>
        <el-form-item>
            <el-button type="primary" @click="GetReceivableList">查询</el-button>
        </el-form-item>
    </el-form>

    <!-- 显示列表 -->
    <el-table :data="ReceivableList" style="width: 100%">
        <el-table-column prop="sCcontractNumber" label="单据编号" align="center" />
        <el-table-column prop="clientName" label="客户名称" align="center" />
        <el-table-column prop="contractTopic" label="关联销售合同" align="center" />
        <el-table-column prop="planAmount" label="本次计划收款金额" align="center">
            <template v-slot="scope">
                {{ scope.row.planAmount.toFixed(2) }}
            </template>
        </el-table-column>
        <el-table-column prop="" label="操作" align="center">
            <template v-slot="scope">
                <el-button @click="shou(scope.row.sCcontractNumber, scope.row.planAmount)">收款(直接收款)</el-button>
                <el-button @click="shou(scope.row.sCcontractNumber, scope.row.planAmount)">收款(预收款抵扣)</el-button>
            </template>
        </el-table-column>
    </el-table>
</template>

<script setup lang='ts'>
import axios from 'axios'
import * as XLSX from 'xlsx';
import { ref, reactive, onMounted, computed } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { useRouter } from 'vue-router';
const router = useRouter();
import http from '../../../http.js'


const show = reactive({
    Pindex: 1,
    Psize: 10,
    lcount: 0,
    pcount: 0,
    AClientName: "",
    ContractTopic: ""
})

//应收列表
const ReceivableList = ref([])
const GetReceivableList = () => {
    axios.get(http.zblnb + '/cw/api/Receivable/GetReceivableList', {
        params: {
            Pindex: show.Pindex,
            Psize: show.Psize,
            AClientName: show.AClientName || '',
            ContractTopic: show.ContractTopic || '',
        }
    })
        .then(res => {
            console.log(res.data.data)
            ReceivableList.value = res.data.data.list;
            show.lcount = res.data.data.lcount;
            show.pcount = res.data.data.pcount;
        })
}

//收款
const shou = (sCcontractNumber: Number, planAmount: number) => {
    router.push('/DirectRefund?sCcontractNumber=' + sCcontractNumber + '&planAmount=' + planAmount);
}




onMounted(() => {
    GetReceivableList();
})



</script>

<style></style>